// pages/list/list.js
import { listData } from '../../mockData/data'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    searchKey: '',
    rightPop: false,
    searchList1: [],
    searchList2: [],
    current: 0,
    secondTab: 0,
    voiceList: [],
    voiceList0: [],
    voiceList1: [],
    voiceList2: [],
    voiceList3: [],
    voiceList4: [],
    productList: [],
    userList: [],
    quanList: [],
    audioInfo:{},
    showPlayer:false,
  },

  onTabClick(e) {
    console.log(e.detail)
    this.setData({
      current: e.detail
    })
  },

  changeSearchTab(e) {
    console.log(e.detail)
    this.setData({
      secondTab: e.detail
    })
    switch (parseInt(e.detail)) {
      case 0:
        this.setData({
          voiceList: this.data.voiceList0
        })
        break;
      case 1:
        this.setData({
          voiceList: this.data.voiceList1
        })
        break;
      case 2:
        this.setData({
          voiceList: this.data.voiceList2
        })
        break;
      case 3:
        this.setData({
          voiceList: this.data.voiceList3
        })
        break;
      case 4:
        this.setData({
          voiceList: this.data.voiceList4
        })
        break;
      default:
        this.setData({
          voiceList: this.data.voiceList0
        })
        break;
    }
  },

  onPlay(e){
    console.log(e.detail)
    this.setData({
      audioInfo:e.detail,
      showPlayer:true,
    })
  },

  closePlayer(){
    this.setData({
      showPlayer:false
    })
    // this.selectComponent('#myPlayer').audioStop() 
  },


  // showPop() {
  //   this.setData({
  //     rightPop: true
  //   })
  // },

  initData() {
    wx.setNavigationBarTitle({ title: listData.title })
    this.setData({
      searchList1: listData.searchList1,
      searchList2: listData.searchList2,
      voiceList: listData.voiceList0,
      voiceList0: listData.voiceList0,
      voiceList1: listData.voiceList1,
      voiceList2: listData.voiceList2,
      voiceList3: listData.voiceList3,
      voiceList4: listData.voiceList4,
      productList: listData.productList,
      userList: listData.userList,
      quanList: listData.quanList
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.initData()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})